package com.wufeng.sort;


/**
 * 冒泡排序 BubbleSort
 * 最佳情况：T(n) = O(n)   最差情况：T(n) = O(n2)   平均情况：T(n) = O(n2)
 */
public class BubbleSort {
    public static void main(String[] args) {
        System.out.println("中文");
    }

    public static int[] sort(int[] array) {
        if (array.length ==0 || array.length == 1){
            return array;
        }
        for (int i = 0; i < array.length - 2; i++) {
            for (int j = 0; j < array.length - 1 - i; j++) {
                if (array[j] > array[j + 1]) {
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }
        return array;
    }
}
